<script setup lang='ts'>
  import { onMounted, reactive, computed } from 'vue';
  import request from '@/api/index';
  import { getAssetsFile } from '@/utils/public';
  import xmimg from '@/components/xmimg.vue';
  import xmdialog from '@/components/xmdialog.vue';
  import { controlStore } from '@/pinia/modules/controller';
  const useControlStore = controlStore()
  import { winList } from '@/pinia/getter'
  const action = reactive({
    show:false,
  })
  const openDialog = ()=>{
    action.show = true
  }
  const topWinList = computed(()=>{
    return winList.value.filter((res:any,index:number)=> index < 8)
  })
  const getList = async()=>{
    const res = await request.winLog()
    const { list=[] } = res.data || {}
    useControlStore.winList = list
  }
  onMounted(()=>{
    getList()
  })
</script>

<template>
  <div>
    <div class="recordList flex-align">
      <div class="list flex-align">
        <div v-for="item in topWinList" class="record">
          <xmimg :src="`@/assets/images/cattleIcon${item.poolId}.png`" class="cattleIcon" />
          <div class="num">x{{ item.magn }}</div>
        </div>
      </div>
      <img @click="openDialog" :src="getAssetsFile('icon1.png')" class="iconBut">
    </div>
    <xmdialog class="newDialogBack" :close-show="2" v-model:dialogshow="action.show">
      <template v-slot:titleImg>
        <img :src="getAssetsFile('titleimg2.png')">
      </template>
      <div class="borderColor">
        <div class="list">
          <div v-for="item in winList" class="record">
            <xmimg :src="`@/assets/images/cattleIcon${item.poolId}.png`" class="cattleIcon" />
            <div class="num">x{{ item.magn }}</div>
          </div>
        </div>
      </div>
    </xmdialog>
  </div>
</template>

<style lang='scss' scoped>
  .record {
    width: 32px;
    height: 41px;
    background: #989BD5;
    border-radius: 6px;
    .cattleIcon {
      width: 28px;
      height: 28px;
      margin: 0 auto;
    }
    .num {
      width: 100%;
      height: 13px;
      line-height: 13px;
      color: #000;
      font-size: 10px;
      font-weight: 500;
      text-align: center;
      border-radius: 0px 0px 6px 6px;
      background: #CACCFF;
    }
  }
  .recordList {
    position: absolute;
    left: 0;
    bottom: 0px;
    width: 100%;
    height: 53px;
    padding: 6px 12px;
    box-sizing: border-box;
    background: #3B3E86;
    border-radius: 12px 12px 0px 0px;
    .list {
      .record {
        margin-right: 5px;
      }
    }
    .iconBut {
      width: 14px;
      height: 14px;
      margin: 0 0 0 auto;
    }
  }
  .newDialogBack {
    .list {
      display: grid;
      grid-template-columns: repeat(8 , 32px);
      grid-gap: 5px 5px;
    }
  }
</style> 